package com.wyj.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wyj.mapper.YlrcRoleAuthoritiesMapper;
import com.wyj.pojo.YlrcRoleAuthorities;
import com.wyj.service.YlrcRoleAuthoritiesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;



/**
* @author mac
* @description 针对表【ylrc_role_authorities】的数据库操作Service实现
* @createDate 2022-11-19 16:06:43
*/
@Service
public class YlrcRoleAuthoritiesServiceImpl extends ServiceImpl<YlrcRoleAuthoritiesMapper, YlrcRoleAuthorities>
implements YlrcRoleAuthoritiesService {

    @Autowired
    YlrcRoleAuthoritiesMapper ylrcRoleAuthoritiesMapper;

    //增加一个角色的权限
    public int addRoleAndMenu(YlrcRoleAuthorities ylrcRoleAuthorities) {
       return ylrcRoleAuthoritiesMapper.insert(ylrcRoleAuthorities);
    }

    //删除一个角色的权限
    public int deleteAndMenu(YlrcRoleAuthorities ylrcRoleAuthorities) {
        QueryWrapper<YlrcRoleAuthorities> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("role_id", ylrcRoleAuthorities.getRoleId());
        queryWrapper.eq("authorities_id", ylrcRoleAuthorities.getAuthoritiesId());
        return ylrcRoleAuthoritiesMapper.delete(queryWrapper);
    }

    //根据角色id 进行删除
    public int deleteRoleAuByRoleId(int roleId) {
        return  ylrcRoleAuthoritiesMapper.deleteByRoleId(roleId);
    }

    public int deleteRoleAuByAuId(int authoritiesId) {
        return ylrcRoleAuthoritiesMapper.deleteByAuthoritiesId(authoritiesId);
    }
}
